/**
 * 3
 *  
 * @Author : Ruoyu Wang
 * @DateTime : 24-10-12 下午6:41
 */

#include <iostream>

using namespace std;

const int mod = 1e9 + 7;

long long pow(long long a, long long k) {
    long long res = 1;
    while (k > 0) {
        if (k % 2 == 1) {
            res = (res * a) % mod;
        }
        a = (a * a) % mod;
        k /= 2;
    }
    return res;
}

int main() {
    int n;
    cin >> n;

    if (n == 1) {
        cout << 0;
    } else if (n == 2) {
        cout << 3;
    } else {
        long long res = pow(3, n);
        long long tmp = 0;
        if (n >= 3) {
            tmp = 6 * pow(3, n - 3) % mod;
            tmp = (tmp + 3 * pow(3, n - 3)) % mod;
        }
        cout << (res - tmp + mod) % mod << endl;
    }

    return 0;
}
